using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Data.Models.Mapping
{
    public class ActualGoodInStockMap : EntityTypeConfiguration<ActualGoodInStock>
    {
        public ActualGoodInStockMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("ActualGoodInStocks");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.StockID).HasColumnName("StockID");
            this.Property(t => t.GoodID).HasColumnName("GoodID");
            this.Property(t => t.DateIn).HasColumnName("DateIn");
            this.Property(t => t.UOMID).HasColumnName("UOMID");
            this.Property(t => t.InputQuantity).HasColumnName("InputQuantity");
            this.Property(t => t.RemainQuantity).HasColumnName("RemainQuantity");
            this.Property(t => t.OutputQuantity).HasColumnName("OutputQuantity");
            this.Property(t => t.InputPrice).HasColumnName("InputPrice");
            this.Property(t => t.CompanyID).HasColumnName("CompanyID");

            // Relationships
            this.HasOptional(t => t.Company)
                .WithMany(t => t.ActualGoodInStocks)
                .HasForeignKey(d => d.CompanyID);
            this.HasOptional(t => t.Product)
                .WithMany(t => t.ActualGoodInStocks)
                .HasForeignKey(d => d.GoodID);
            this.HasOptional(t => t.Stock)
                .WithMany(t => t.ActualGoodInStocks)
                .HasForeignKey(d => d.StockID);

        }
    }
}
